/* 

包含n个接口请求函数的 模块
*/
import myAxios from './myAxios'

// 1.根据经纬度获取位置详情                    函数返回一个promise
export const reqAddress = (latitude, longitude) => myAxios.get(`/position/${latitude},${longitude}`)

// 2.获取食品分类列表
export const reqFoodCategorys = () => myAxios.get('/index_category')

// 3.根据经纬度获取商铺列表
export const reqShops = ({
  latitude,
  longitude
}) => myAxios.get('/shops', {
  params: {
    latitude,
    longitude
  }
})
//4.根据经纬度和关键字搜索商铺列表
export const reqSearchShops = ({
  geohash,
  keyword
}) => myAxios.get('/search_shops', {
  params: {
    geohash,
    keyword
  }
})
// 5.获取用户名密码登陆
export const reqPwdLogin = ({
  name,
  pwd,
  captcha
}) => myAxios.post('/login_pwd', {
  name,
  pwd,
  captcha
})

// 6.获取发送短信验证码
export const reqSendCode = (phone) => myAxios.get('/sendcode', {
  params: {
    phone
  }
})
// 7.获取手机号验证码登陆
export const reqLoginSms = ({
  phone,
  code
}) => myAxios.post('/login_sms', {
  phone,
  code
})
// 8.自动登陆
export const reqAutoLogin = () => myAxios.get('/auto_login')



// 9.获取商家的食品goods
export const reqGoods = () => myAxios.get('/goods')

// 10.获取商家的评论ratings
export const reqRatings = () => myAxios.get('/ratings')

// 11.获取商家的信息info
export const reqInfo = () => myAxios.get('/info')



// 2.获取商家全部信息shop
export const reqShop = (id) => myAxios.get(`/shop/${id}`)


// 测试请求mock接口的数据
// myAxios.get('/goods').then(res => {
//   console.log(res);
// })